/**
 * Project of Vehicle Routing Problem with Time Windows implements 
 * some of well-known algorithms for solving VRPTW and presents new 
 * one.
 *
 * @author Michal Drobny  
 */

package logic.destination;

import java.util.UUID;

import util.Cloneable;

/**
 * Represents simple abstract object for destination. Destination contains the
 * unique id and name.
 * 
 * @author Michal Drobny
 * @date 16.10.2014
 */
public abstract class Destination implements Cloneable<Destination> {

	protected final String name;
	protected final UUID id;

	/**
	 * Constructor.
	 * 
	 * @param name
	 */
	public Destination(String name) {
		super();
		this.name = name;
		this.id = UUID.randomUUID();
	}
	
	/**
	 * Constructor.
	 * 
	 * @param name
	 *            The name
	 * @param id
	 *            The ID
	 */
	public Destination(String name, UUID id) {
		super();
		this.name = name;
		this.id = id;
	}

	/**
	 * @return the id
	 */
	protected UUID getId() {
		return id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Destination))
			return false;
		Destination other = (Destination) obj;
		if (id == null)
			if (other.id != null)
				return false;
			else
				return true;
		return id.equals(other.id);
	}

	@Override
	public abstract Destination clone();
}